1. Field of the Invention
The present invention relates to a frequency-variable RC oscillator having an oscillation frequency to be set programmable and a microcomputer incorporating the same.
2. Description of the Related Art
In the microcomputer, accurate operating clock is required in order to positively implement various operations depending upon the application thereof. For this reason, it is a practice for such a microcomputer to utilize external oscillation, such as of a ceramic filter or quartz oscillator, to generate a correct operating clock for operation on the basis thereof.
At and around powered on timing, external oscillation is not stabilized. For this reason, an RC oscillator is incorporated to supply an operating clock until the external oscillation is stabilized.
However, the RC oscillator incorporated in the microcomputer largely varies in oscillation frequency due to variation in manufacture or change in temperature or power voltage. Accordingly, where an RC oscillator is used as a clock supply source in executing the main process of a microcomputer, there is a need for development of such software as to absorb such frequency variation.
It is an object of the present invention to make the oscillation frequency of an RC oscillator set programmable there by compensating for frequency variation caused due to variation in manufacture or the like and supplying a correct operating clock.
Meanwhile, another object of the invention is to incorporate an RC oscillator variable in oscillation frequency in a microcomputer and utilized as a clock supply source in executing the main process of the microcomputer, thereby facilitating the development of software and reducing the circuit parts for external oscillation and hence cost.
A frequency-variable RC oscillator of the present invention comprises: an RC oscillator including a resistance and capacitor; a counter for counting the number of source oscillation clocks from the RC oscillator; a frequency setting register for setting the number of source oscillation clocks corresponding to a desired oscillation frequency; and a comparator for comparing between a count value of the counter and a set value of the frequency setting register; whereby a clock is outputted depending upon a result of comparison by the comparator.
According to the above configuration, the oscillation frequency of an output clock can be set based on a step of a period of source oscillation supplied by the RC oscillator in accordance with a set value of the frequency setting register. Namely, according to this circuit, by increasing the source oscillation frequency and a prepared bit length of the frequency setting register, oscillation frequency can be set with higher accuracy thereby compensating for the frequency variation due to variation in manufacture or the like. Thus, correct operating clock can be provided.
Meanwhile, a microcomputer of the present invention is a microcomputer for generating a system clock in order for self-operation by incorporating a frequency-variable RC oscillator configured as above, comprising: a counter for counting the number of source oscillation clocks from the RC oscillator; a frequency setting register for setting the number of source oscillation clocks in accordance with a desired oscillation frequency; a comparator for comparing between a count value of the counter and a set value of the frequency setting register; and a clock generator for generating a system clock on the basis of a clock outputted depending on a result of comparison by said comparator.
According to the microcomputer configured as above, an inexpensive RC oscillation circuit can be utilized as a clock supply source in executing the main process. Accordingly, it is possible to facilitate software development and reduce the circuit parts for external oscillation and hence the cost.